home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Chipmunk Basic 3.2.8
/
ucase.bas
< prev
Wrap
BASIC Source File
|
1995-10-04
|
1KB
|
33 lines
100 rem subroutine tests
110 b$ = "HelLo"
120 print countcaps(b$);" capital letters in ";b$
130 print ucase$(b$);" is all capital letters"
140 print "{";spc$(4);"} should be 4 spaces between the brackets"
150 for i = 1 to 10 : print fib(i); : next i : print " are fibonacci numbers"
190 end
191 '********
8000 sub fib(n) : rem recursive fibonacci number
8010 if n < 2 then return (1)
8020 return (fib(n-1)+fib(n-2))
9000 sub ucase$(a$,b$,i,c,n) : rem convert a$ to upper case
9010 b$ = ""
9020 n = len(a$)
9030 for i = 1 to n
9040 c = asc(mid$(a$,i,1))
9050 if c > 96 then c = c-32
9060 b$ = b$+chr$(c)
9070 next i
9080 return (b$)
9100 sub countcaps(a$,i,n,c$) : rem count capital letters in a$
9110 n = 0
9120 for i = 1 to len(a$)
9130 c$ = mid$(a$,i,1) : if c$ >= "A" and c$ <= "Z" then n = n+1
9140 next i
9150 return (n)
9200 sub spc$(n,b$,i) : rem create a string of n spaces
9210 b$ = ""
9220 for i = 1 to n : b$ = b$+" " : next i
9230 return (b$)
9980 '********
9990 end